<template>
  <div>
    lifecycle {{ myname }}
    <button @click="handleClick">click</button>
  </div>
</template>

<script>
import { onMounted, onUnmounted, onUpdated, ref } from 'vue'

export default {
  setup () {
    // 注册回调
    onMounted(() => {
      // new Swiper
      console.log('onMounted')
    })
    onUpdated(() => {
      console.log('onUpdated')
    })

    onUnmounted(() => {
      console.log('onUnmounted', '销毁定时器，取消订阅')
    })

    const myname = ref('lisa')
    const handleClick = () => {
      myname.value = 'json'
    }

    return {
      myname,
      handleClick
    }
  }
}
</script>
